package com.tul.exercise.base.subjectobserver;

/**
 * @author tul on 2018/7/22.
 */
public class CurrentConditionDisplay implements Observer,DisplayElement{
    /**
     * 数据
     */
    private DataInfo data;

    /**
     * 主题对象
     */
    private Subject subject;

    public CurrentConditionDisplay(Subject subject) {
        this.subject = subject;
        this.subject.addObserver(this);

    }

    /**
     * 更新
     */
    public void update(DataInfo data) {
        this.data = data;
        display();
    }

    /**
     * 显示数据
     */
    public void display() {
        System.out.println("CurrentConditionDisplay:" + data.toString());
    }

    public DataInfo getData() {
        return data;
    }

    public void setData(DataInfo data) {
        this.data = data;
    }
}
